package com.zyt.springboot.CalculationPI;

public class PI {//割圆法计算圆周率
    public static void main(String[] args) {
        double sex = Math.sqrt(2); //45度角的 斜边长
        int k = 25; //切割次数
        int numberOfSides = 4 << k; //多边形边数
        for (int i = 0 ; i <= k; i ++){
            sex = Math.sqrt( 2 * sex * sex  + 2 * Math.sqrt(sex * sex - 1) * sex) ;
        }
        System.out.println( numberOfSides * 2  / sex );
    }
}
